package com.hawthorn.redis.controller;

import com.hawthorn.entity.po.SysBizConfPO;
import com.hawthorn.redis.service.bizconf.SysBizConfCacheService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>todo 业务配置缓存</p>
 * @author: andy.ten@tom.com | xukaixing@hotmail.com
 * @created: 2021/12/19 2:25 PM
 * @version v1.0.1
 * @copyright: Copyright (c)  andyten
 */
@Api(tags = {"redis-sysbizconf"})
@RestController
@RequestMapping("/bizconf")
@Slf4j
public class BizConfCacheController
{
  @Autowired
  private SysBizConfCacheService sysBizConfCacheService;

  /**
   * <p>todo 重新加载业务参数配置</p>
   * @author: andy.ten@tom.com
   * @date: 2021/12/20 8:35 PM
   * @version: 1.0.1
   */
  @ApiOperation(value = "加载->重新初始化业务参数", notes = "重新初始化业务参数")
  @ApiImplicitParams({
  })
  @GetMapping(value = "reloadBizConf")
  public void reloadAppConf()
  {
    sysBizConfCacheService.init();
  }


  /**
   * <p>todo 根据key重新加载业务参数</p>
   * @author: andy.ten@tom.com ｜ xukaixing@hotmail.com
   * @date: 2022/8/7 15:17
   * @version: 1.0.1
   */
  @ApiOperation(value = "加载-> 加载单个业务参数", notes = "加载单个业务参数")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "SysBizConfPO", value = "SysBizConfPO", dataTypeClass = Object.class)
  })

  @PostMapping(value = "/reloadBizConfById")
  public void reloadBizConfById(@RequestBody SysBizConfPO sysBizConfPO)
  {
    sysBizConfCacheService.reloadBizConfById(sysBizConfPO);
  }
}
